// 属性相关API
import request from "@/utils/request";
import type { CategotyResponseData, AttrResponseData, Attr } from "./type";
// 属性管理模块接口地址
enum API {
    // 获取一级分类接口地址
    C1_URL = '/admin/product/getCategory1',
    // 获取二级分类接口地址
    C2_URL = '/admin/product/getCategory2',
    // 获取三级分类接口地址
    C3_URL = '/admin/product/getCategory3',
    // 获取商品属性接口地址
    ATTR_URL = '/admin/product/attrInfoList',
    // 添加或者修改已有的属性接口地址
    ADDORUPDATEATTR_URL = '/admin/product/saveAttrInfo',
    // 删除已有属性接口地址
    DELETE_URL = '/admin/product/deleteAttr'
}

// 获取一级分类接口方法
export const reqC1 = () => request.get<any, CategotyResponseData>(API.C1_URL)
// 获取二级分类接口方法
export const reqC2 = (category1Id: number | string) => request.get<any, CategotyResponseData>(API.C2_URL + `/${category1Id}`)
// 获取三级分类接口方法
export const reqC3 = (category2Id: number | string) => request.get<any, CategotyResponseData>(API.C3_URL + `/${category2Id}`)
// 获取商品属性接口方法
export const reqAttr = (category1Id: number | string, category2Id: number | string, category3Id: number | string) => request.get<any, AttrResponseData>(API.ATTR_URL + `/${category1Id}/${category2Id}/${category3Id}`)
// 新增洪泽修改已有属性
export const reqAddOrUpdateAttr = (data: Attr) => {
    return request.post<any, any>(API.ADDORUPDATEATTR_URL, data)
}
export const reqRemoveAttr = (attrId: number) => {
    return request.delete<any, any>(API.DELETE_URL + `/${attrId}`)
}